const Controller = require('egg').Controller;

class GradeController extends Controller {
  async grade() {
    const { ctx, app } = this;
    const data = await ctx.service.grade.grade()
    ctx.body = data;
  }

  async addGrade() {
    const { ctx, app } = this;
    const data = await ctx.service.grade.addGrade()
    ctx.body = data;
  }
  async updateGrade() {
    const { ctx, app } = this;
    const data = await ctx.service.grade.updateGrade()
    ctx.body = data;
  }

  async deleteGrade() {
    const { ctx, app } = this;
    const data = await ctx.service.grade.deleteGrade()
    ctx.body = data;
  }

  async searchGrade() {
    // searchGrade
    const { ctx, app } = this;
    const data = await ctx.service.grade.searchGrade()
    ctx.body = data;
  }

  async pageGrade() {
    const { ctx } = this;
    // try {
    //   ctx.validate({ page: { require: true } }, ctx.query);
    // } catch (error) {
    //   ctx.status = 400;
    //   ctx.body = { code: 0, msg: '参数传递有误', error: error.errors[0] }
    //   return;
    // }
    const data = await ctx.service.grade.pageGrade()
    ctx.body = data;
  }

  async betchDelete() {
    const data = await ctx.service.grade.betchDelete()
    ctx.body = data;
  }

  async gradeAll() {
    const data = await this.ctx.service.grade.gradeAll()
    this.ctx.body = data;
  }
}

module.exports = GradeController;